<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="renderer" content="webkit" />
    <meta charset="UTF-8">
    <title>用户注册</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/register.css">
    <script>
        window.onload=function () {
            $('#username').mouseout(function () {
                if ($('#username').val() == "" || $('#username'.val() == undefined)) {
                    $('#username').attr('placeholder', '请输入账号');
                    $('#next').attr('disabled', true)
                }
                else {
                    $('#next').attr('disabled', false)
                }
            })
            $('#password').mouseout(function () {
                if ($('#password').val() == "" || $('#password'.val() == undefined)) {
                    $('#password').attr('placeholder', '请输入密码');
                    $('#next').attr('disabled', true)
                }
                else {
                    $('#next').attr('disabled', false)
                }
            })
            $('#confirmPassword').mouseout(function () {
                if ($('#confirmPassword').val() == "" || $('#confirmPassword'.val() == undefined)) {
                    $('#confirmPassword').attr('placeholder', '请确认密码');
                    $('#next').attr('disabled', true)
                }
                else {
                    $('#next').attr('disabled', false)
                }
            })
            $('#confirmPassword').mouseup(function () {
                if ($('#confirmPassword').val()!== $('#password').val()) {
                    $('.kong').addClass('alert alert-danger').html("两次输入密码不一致！");
                    $('#next').attr('disabled', true)
                }
                else {
                    $('.kong').remove()
                    $('#next').attr('disabled', false)
                }
            })
        }
    </script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-sm-8 col-sm-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="modal-title text-center"><img src="${pageContext.request.contextPath}/static/imgs/logo2.png" style="width:210px" ></h3>
                </div>
                <div class="panel-body">
                    <form id="demoForm" method="post" class="form-horizontal" action="${pageContext.request.contextPath}/registerInfo.action">
                        <div class="form-group">
                            <label class="col-sm-4 control-label" for="username">账号</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" id="username" name="username" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label" for="password">密码</label>
                            <div class="col-sm-5">
                                <input type="password" class="form-control" id="password" name="password" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label" for="confirmPassword">密码确认</label>
                            <div class="col-sm-5">
                                <input type="password" class="form-control" id="confirmPassword" name="confirmPassword"  />
                            </div>
                        </div>
                        <div class="form-group">
                            <div style="color: red" class=" kong col-sm-5  col-sm-offset-4">
                                ${msg}
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-5 col-sm-offset-4">
                                <button type="submit" style="width: 100%;"  class="btn" id="next">下一步</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery.validate.js"></script>
<script>
    $(document).ready(function () {
        $("#demoForm").validate({
            rules:{
                username:{
                    required:true,
                    rangelength:[2,10],
                },
                password:{
                    required:true,
                    minlength:2,
                    maxlength:16
                },
            },
            messages:{
                username:{
                    required:"用户名不能为空！",
                    minlength:"用户名最小为2位！",
                    maxlength:"用户名最大为10位！",
                    rangelength:"用户名应为2-10位！",
                    remote:'用户名不存在！'
                },
                password:{
                    required:"密码不能为空！",
                    minlength:"密码最小为2位！",
                    maxlength:"密码最大为16位！"
                },


            }
        });


    });
</script>

</body>
</html>